package com.moekr.demo.dubbo.consumer;

import com.alibaba.dubbo.config.annotation.Reference;
import com.moekr.demo.dubbo.protocol.*;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
public class DemoController {
    @Reference(version = "1.0.0")
    private DemoService service;
    @Reference(version = "1.0.0")
    private LicslanService licslanService;
    @Reference(version = "1.0.0")
    private LicslanService1 licslanService1;
    @Reference(version = "1.0.0")
    private LicslanService2 licslanService2;
    @Reference(version = "1.0.0")
    private LicslanService3 licslanService3;
    @Reference(version = "1.0.0")
    private LicslanService4 licslanService4;
    @Reference(version = "1.0.0")
    private LicslanService5 licslanService5;



    @GetMapping("/{id}")
    public Map<String, Object> request(@PathVariable int id) {
        DemoObject object = service.request(id);
        Map<String, Object> response = new HashMap<>();
        if (object != null) {
            response.put("err", 0);
            response.put("res", object);
        } else {
            response.put("err", 300);
            response.put("msg", "no result");
        }
        return response;
    }

    @GetMapping("/licslan")
    public Map<String, Object> request() {
        String name = "hello world  this is created by hwl";
        String Str = licslanService.get(name);
        Map<String, Object> response = new HashMap<>();
        if (Str != null) {
            response.put("err", 0);
            response.put("res", Str);
        } else {
            response.put("err", 200);
            response.put("msg", "no result");
        }
        return response;
    }

    @GetMapping("/licslan1")
    public Map<String, Object> request1() {
        String name = "hello world  this is created by hwl";
        String Str = licslanService1.get(name);
        Map<String, Object> response = new HashMap<>();
        if (Str != null) {
            response.put("err", 0);
            response.put("res", Str);
        } else {
            response.put("err", 200);
            response.put("msg", "no result");
        }
        return response;
    }

    @GetMapping("/licslan2")
    public Map<String, Object> request2() {
        String name = "hello world  this is created by hwl";
        String Str = licslanService2.get(name);
        Map<String, Object> response = new HashMap<>();
        if (Str != null) {
            response.put("err", 0);
            response.put("res", Str);
        } else {
            response.put("err", 200);
            response.put("msg", "no result");
        }
        return response;
    }

    @GetMapping("/licslan3")
    public Map<String, Object> request3() {
        String name = "hello world  this is created by hwl";
        String Str = licslanService3.get(name);
        Map<String, Object> response = new HashMap<>();
        if (Str != null) {
            response.put("err", 0);
            response.put("res", Str);
        } else {
            response.put("err", 200);
            response.put("msg", "no result");
        }
        return response;
    }

    @GetMapping("/licslan4")
    public Map<String, Object> request4() {
        String name = "hello world  this is created by hwl";
        String Str = licslanService4.get(name);
        Map<String, Object> response = new HashMap<>();
        if (Str != null) {
            response.put("err", 0);
            response.put("res", Str);
        } else {
            response.put("err", 200);
            response.put("msg", "no result");
        }
        return response;
    }

    @GetMapping("/licslan5")
    public Map<String, Object> request5() {
        String name = "hello world  this is created by hwl";
        String Str = licslanService5.get(name);
        Map<String, Object> response = new HashMap<>();
        if (Str != null) {
            response.put("err", 0);
            response.put("res", Str);
        } else {
            response.put("err", 200);
            response.put("msg", "no result");
        }
        return response;
    }

}
